import {defineStore} from "pinia"

const state = () => ({
	sidebarStatus: {
		opened: !+localStorage.getItem('sidebarStatus'),
		withoutAnimation: false
	},
	device: 'desktop'
})

export const useStoreApp = defineStore({
	id: 'app',
	state,
	actions: {
		ToggleSideBar() {
			if (this.sidebarStatus.opened) {
				localStorage.setItem('sidebarStatus', String(1))
			} else {
				localStorage.setItem('sidebarStatus', String(0))
			}
			this.sidebarStatus.opened = !this.sidebarStatus.opened
		},
		CloseSideBar({withoutAnimation}) {
			localStorage.setItem('sidebarStatus', String(1))
			this.sidebarStatus.opened = false
			this.sidebarStatus.withoutAnimation = withoutAnimation
		}
	}
})

export default useStoreApp;
